/*
 * @Description: 答约管理
 * @Author: 龙春雨
 * @Date: 2023-04-06 14:07:24
 */
import { CONTRACT_STATUS_DIC, RESERVE_AGGREE_LIST } from '@/const/type';
import { cardid } from '@/util/validate';
export const tableOption = {
  ...window.$crudMixins.tableOptions,
  viewBtn: false,
  addBtn: false,
  editBtn: false,
  delBtn: false,
  labelWidth: 100,
  searchLabelWidth: 90,
  menuWidth: 120,
  span: 24,
  column: [
    {
      label: '协议编号',
      prop: 'id',
      search: true,
      type: 'number',
      controls: false,
    },
    {
      label: '签署状态',
      prop: 'status',
      type: 'select',
      search: true,
      dicData: CONTRACT_STATUS_DIC,
    },
    {
      label: '协议类型',
      prop: 'type',
      type: 'select',
      search: true,
      dicData: RESERVE_AGGREE_LIST,
    },
    {
      label: '宠物编号',
      prop: 'petCodes',
      search: true,
    },
    {
      label: '宠物昵称',
      prop: 'petNames',
      overHidden: true,
      search: true,
    },
    {
      label: '手机号',
      prop: 'phone',
      search: true,
    },
    {
      label: '签约日期',
      search: true,
      searchType: 'daterange',
      format: 'yyyy-MM-dd',
      valueFormat: 'yyyy-MM-dd',
      type: 'date',
      prop: 'signDate',
    },
  ],
};
//领养协议
export const formOption = (detail) => {
  return {
    border: true,
    align: 'center',
    menuAlign: 'center',
    span: 12,
    menuBtn: false,
    detail: detail,
    labelWidth: 130,
    group: [
      {
        label: '宠物信息',
        labelWidth: 130,
        arrow: false,
        column: [
          {
            label: '宠物编号',
            prop: 'petId',
            formslot: true,
            rules: [
              {
                required: true,
                message: '请输入宠物编号',
                trigger: 'change',
              },
            ],
          },
          {
            label: '宠物昵称',
            disabled: true,
            placeholder: '根据宠物编号自动带出',
            prop: 'petName',
          },
          {
            label: '宠物品种',
            disabled: true,
            placeholder: '根据宠物编号自动带出',
            prop: 'petTypeName',
          },
          {
            label: '性别',
            disabled: true,
            placeholder: '根据宠物编号自动带出',
            prop: 'petSex',
          },
          {
            label: '所属爱心收容站',
            disabled: true,
            prop: 'baseName',
            placeholder: '根据宠物编号自动带出',
          },
          {
            label: '收容站位置',
            disabled: true,
            prop: 'baseAddress',
            placeholder: '根据宠物编号自动带出',
          },
        ],
      },
      {
        label: '领养信息',
        labelWidth: 130,
        arrow: false,
        column: [
          {
            label: '领养人手机号',
            prop: 'phone',
            formslot: true,
            rules: [
              {
                required: true,
                message: '请选择领养人手机号',
                trigger: 'change',
              },
            ],
          },
          {
            label: '领养人姓名',
            prop: 'adoptName',
            disabled: true,
            maxlength: 20,
            rules: [
              {
                required: true,
                message: '请输入领养人姓名',
                trigger: 'change',
              },
            ],
          },
          {
            label: '领养人身份证号',
            disabled: true,
            prop: 'adoptCard',
            rules: [
              {
                required: true,
                message: '请输入领养人身份证号',
              },
              {
                validator: (rule, value, callback) => {
                  if (cardid(value)[0]) {
                    callback(new Error(cardid(value)[1]));
                  } else {
                    callback();
                  }
                },
                trigger: 'blur',
              },
            ],
          },
          {
            label: '家庭住址',
            prop: 'adoptAddress',
            rules: [
              {
                required: true,
                message: '请输入家庭住址',
                trigger: 'blur',
              },
              {
                min: 1,
                max: 50,
                message: '长度不能超过50个字符',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '用户ID',
            disabled: true,
            placeholder: '根据手机号码自动带出',
            prop: 'userId',
          },
          {
            label: '用户昵称',
            disabled: true,
            placeholder: '根据手机号码自动带出',
            prop: 'nickName',
          },
        ],
      },
    ],
  };
};
//送养协议
export const outOption = {
  border: true,
  align: 'center',
  menuAlign: 'center',
  span: 12,
  menuBtn: false,
  labelWidth: 130,
  submitBtn: false,
  emptyBtn: false,
  group: [
    {
      label: '送养人信息',
      arrow: false,
      column: [
        {
          label: '送养人手机号',
          prop: 'phone',
          formslot: true,
          rules: [
            {
              required: true,
              message: '请选择送养人手机号',
              trigger: 'change',
            },
          ],
        },
        {
          label: '送养人姓名',
          prop: 'adoptName',
          maxlength: 20,
          disabled: true,
          placeholder: '根据手机号码自动带出',
        },
        {
          label: '送养人身份证号',
          prop: 'adoptCard',
          disabled: true,
          placeholder: '根据手机号码自动带出',
          // rules: [
          //   {
          //     required: true,
          //     message: '请输入领养人身份证号',
          //   },
          //   {
          //     validator: (rule, value, callback) => {
          //       if (cardid(value)[0]) {
          //         callback(new Error(cardid(value)[1]));
          //       } else {
          //         callback();
          //       }
          //     },
          //     trigger: 'blur',
          //   },
          // ],
        },
        {
          label: '家庭住址',
          prop: 'adoptAddress',
          disabled: false,
          rules: [
            {
              required: true,
              message: '请输入家庭住址',
              trigger: 'blur',
            },
            {
              min: 1,
              max: 50,
              message: '长度不能超过50个字符',
              trigger: 'blur',
            },
          ],
        },
        {
          label: '用户ID',
          disabled: true,
          placeholder: '根据手机号码自动带出',
          prop: 'userId',
        },
        {
          label: '用户昵称',
          disabled: true,
          placeholder: '根据手机号码自动带出',
          prop: 'nickName',
        },
      ],
    },
  ],
};
